home *** CD-ROM | disk | FTP | other *** search
/ Star Trek Starfleet Academy Mini Omnipedia / MINI_OMNI.ISO / pc / omni_v2.dxr / 00375_Search Events.ls < prev    next >
Encoding:
Text File  |  1996-04-15  |  11.5 KB  |  375 lines

  1. global oIndexScroller, gGlobalStepCount, gLocalStepCount, gInputField, gModeState, gAlphaState, gCurrEntryAttrib, gNewSetIsHereF, gchunksize, gFirstHotWord, gEpisFTchunksizeK, oIndexMediator, gTheFTword, gFTsearchscope, gModeNameLU, gNumofHits, gStatusField, gStardateLU, gStardLUlistSize, gFTstartSND, gESstartSND, gIndexSND, oTextScroller, gIndxScrollFldK, gTheMseWord, gStashedHitsList, gActiveResTopWin, gNopeSND, gholdTheFTword, gBeginCurlyQ, gEndCurlyQ, gComputerTypeK, gdescfield, gAposCurlyQ
  2.  
  3. on hFindThisEntry
  4.   hilite char 999 of field gInputField
  5.   hReportStatus("Entry search commencing")
  6.   hearit(gESstartSND)
  7.   mSetDontResetLine(oIndexScroller, 0)
  8.   set Lkall to field gInputField
  9.   put " for [" & Lkall & "]" after field gStatusField
  10.   set Lkall to hSwapIfSpecial(Lkall)
  11.   hDetectMode(Lkall)
  12.   hUserSelectEntry()
  13.   if not (gModeState = #CHRO) then
  14.     set lk to char 1 of Lkall
  15.     set Lknum to charToNum(lk)
  16.     if (Lknum >= 48) and (Lknum <= 122) then
  17.       hSetIndex(lk, Lkall)
  18.       hProcess(Lkall)
  19.     else
  20.       if (Lknum >= 48) and (Lknum <= 57) then
  21.         hProcess(Lkall)
  22.       else
  23.         if hIsaQuote(lk) then
  24.           set lk to char 2 of Lkall
  25.           hSetIndex(lk, Lkall)
  26.           hProcess(Lkall)
  27.         else
  28.           hReportStatus("Search unable to resolve...")
  29.         end if
  30.       end if
  31.     end if
  32.   else
  33.     set lk to char 1 to 2 of Lkall
  34.     hSetIndex(lk, Lkall)
  35.     hProcess(Lkall)
  36.   end if
  37. end
  38.  
  39. on hMatchEntryToIndexLine pN
  40.   put line pN of field gIndxScrollFldK into field gInputField
  41.   hilite char 999 of field gInputField
  42.   set Lkall to field gInputField
  43.   hSetIndex(hFilterSearchChars(Lkall), Lkall, 1)
  44.   hProcess(field gInputField)
  45. end
  46.  
  47. on hTopicFind pNameToFind
  48.   put pNameToFind into field gInputField
  49.   hilite char 999 of field gInputField
  50.   hCloseTopWin()
  51.   forget(window gActiveResTopWin)
  52.   hSetMode(#ENCY)
  53.   hMiniFind()
  54. end
  55.  
  56. on hMiniFind pUpdateF
  57.   set Lkall to field gInputField
  58.   hSetIndex(hFilterSearchChars(Lkall), Lkall, pUpdateF)
  59.   hProcess(Lkall)
  60. end
  61.  
  62. on hSetIndex pLetter, pEntry, pUpdateF
  63.   hearit(gIndexSND)
  64.   if gModeState = #EPISSUB then
  65.     set pLetter to gAlphaState
  66.     mSetDontResetLine(oIndexScroller, 1)
  67.   end if
  68.   if (pLetter = gAlphaState) or (gModeState = #FoundSet) then
  69.     if pEntry = " " then
  70.       hearit(gNopeSND)
  71.       abort()
  72.     end if
  73.     set Lthelocalitemnum to hMatchToAttrib(pLetter, pEntry)
  74.     if not pUpdateF then
  75.       mShiftWindowToEntry(oIndexScroller, Lthelocalitemnum, 0)
  76.     end if
  77.     return 
  78.   else
  79.     hGetNewAttrList(pLetter, 0)
  80.     set Lthelocalitemnum to hMatchToAttrib(pLetter, pEntry)
  81.     if voidp(Lthelocalitemnum) then
  82.       return 
  83.     else
  84.       if not pUpdateF then
  85.         mShiftWindowToEntry(oIndexScroller, Lthelocalitemnum, 0)
  86.       else
  87.         mMatchScrollBar(oIndexScroller)
  88.       end if
  89.     end if
  90.   end if
  91. end
  92.  
  93. on hMatchToAttrib pLetter, pEntry
  94.   global gHyperExceptions
  95.   if gModeState = #FoundSet then
  96.     set LthisMode to hGetMode(pEntry)
  97.     set pLetter to hCapitalize(pLetter)
  98.     set LthisItem to hConvertAlphaToItem(pLetter)
  99.     set LmyAttrGroup to mGetModesAttribGroup(oIndexMediator, LthisMode, LthisItem)
  100.     set gCurrEntryAttrib to getaProp(LmyAttrGroup, pEntry)
  101.     if mWhatFSlistType(oIndexScroller) = 1 then
  102.       set Lentrynm to mGetCurrLUShort(oSLlookup, pEntry)
  103.     else
  104.       set Lentrynm to pEntry
  105.     end if
  106.     set LthisFoundList to mGetModesAttribGroup(oIndexMediator, #FoundSet, 1)
  107.     set Lnum to findPos(LthisFoundList, Lentrynm)
  108.     hSetGlobalCounter(Lnum)
  109.     hSetLocalCounter(Lnum)
  110.     if voidp(gCurrEntryAttrib) then
  111.     end if
  112.     return Lnum
  113.   end if
  114.   hUpdateCurrItem(pLetter)
  115.   set LmyAttrList to mGrabCurrAttrList(oIndexMediator, gModeState)
  116.   hSetLocalCounter(findPos(LmyAttrList, pEntry))
  117.   set vHoldAttrList to LmyAttrList
  118.   set vHoldpletter to pLetter
  119.   if gModeState = #ENCY then
  120.     if voidp(gLocalStepCount) then
  121.       hputmsg(">***hMatchToAttrib: Is this >" & pEntry & "<an exception?")
  122.       set vHoldEntry to pEntry
  123.       set pEntry to getaProp(gHyperExceptions, pEntry)
  124.       if not voidp(pEntry) then
  125.         set pLetter to char 1 of pEntry
  126.         hUpdateCurrItem(pLetter)
  127.         set LmyAttrList to mGrabCurrAttrList(oIndexMediator, gModeState)
  128.         hSetLocalCounter(findPos(LmyAttrList, pEntry))
  129.         if gLocalStepCount then
  130.         end if
  131.       else
  132.         set gLocalStepCount to pEntry
  133.       end if
  134.       if voidp(gLocalStepCount) then
  135.         set pEntry to vHoldEntry
  136.         set pEntry to hTryCap(pEntry)
  137.         hSetLocalCounter(findPos(LmyAttrList, pEntry))
  138.         if gLocalStepCount then
  139.           hReportStatus("Entry Found:" && pEntry)
  140.         end if
  141.         if voidp(gLocalStepCount) then
  142.           set pEntry to vHoldEntry
  143.           set vHoldEntry to pEntry
  144.           set pEntry to hLastNameFirst(pEntry)
  145.           set pLetter to char 1 of pEntry
  146.           hUpdateCurrItem(pLetter)
  147.           set LmyAttrList to mGrabCurrAttrList(oIndexMediator, gModeState)
  148.           hSetLocalCounter(findPos(LmyAttrList, pEntry))
  149.           if gLocalStepCount then
  150.             hReportStatus("Entry Found:" && pEntry)
  151.           end if
  152.           if voidp(gLocalStepCount) then
  153.             set pEntry to vHoldEntry
  154.             set vHoldEntry to pEntry
  155.             set pEntry to hIsADoctor(pEntry)
  156.             hSetLocalCounter(findPos(LmyAttrList, pEntry))
  157.             if gLocalStepCount then
  158.               hReportStatus("Entry Found:" && pEntry)
  159.             end if
  160.             if voidp(gLocalStepCount) then
  161.               set pEntry to vHoldEntry
  162.               set vHoldEntry to pEntry
  163.               set pEntry to hTryHarder(pEntry)
  164.               set LmyAttrList to vHoldAttrList
  165.               set pLetter to vHoldpletter
  166.               hUpdateCurrItem(pLetter)
  167.               hSetLocalCounter(findPos(LmyAttrList, pEntry))
  168.               if gLocalStepCount then
  169.                 hReportStatus("Entry Found:" && pEntry)
  170.               end if
  171.             end if
  172.           end if
  173.         end if
  174.       end if
  175.     end if
  176.   end if
  177.   if voidp(gLocalStepCount) then
  178.     if (gModeState = #EPIS) and (pEntry contains "Star Trek") then
  179.       set pEntry to " " & pEntry
  180.     end if
  181.     if gModeState <> #CHRO then
  182.       hReportStatus("Still looking for a match...")
  183.       sort(LmyAttrList)
  184.       hSetLocalCounter(findPosNear(LmyAttrList, pEntry))
  185.     else
  186.       hearit(gNopeSND)
  187.       hReportStatus("No exact match for that year in the Chronology.")
  188.       abort()
  189.     end if
  190.   end if
  191.   if gLocalStepCount > count(LmyAttrList) then
  192.     hReportStatus("Entry" && pEntry & " not found even after trying alternative methods.")
  193.     hearit(gNopeSND)
  194.     abort()
  195.   end if
  196.   if gModeState <> #EPISSUB then
  197.     mUpdateGlobalFromLocal(oIndexMediator)
  198.   else
  199.     hSetGlobalCounter(gLocalStepCount)
  200.   end if
  201.   set gCurrEntryAttrib to getAt(LmyAttrList, gLocalStepCount)
  202.   return gLocalStepCount
  203. end
  204.  
  205. on hGetNewAttrList pLetter, pSortFlag
  206.   set pLetter to hCapitalize(pLetter)
  207.   if not (gModeState = #EPISSUB) and not (gModeState = #FoundSet) then
  208.     mSetCurrAttrList(oIndexMediator, "ATTRIB_" & pLetter & "_" & gModeState, gModeState)
  209.     if the result = 0 then
  210.       abort()
  211.     end if
  212.     hSetAlphaState(hCapitalize(pLetter))
  213.     if gModeState = #CHRO then
  214.     else
  215.       if pSortFlag then
  216.         hReportStatus("Sorting...")
  217.         set Ls to the ticks
  218.         sort(mGrabCurrAttrList(oIndexMediator, gModeState))
  219.         set Ls to the ticks - Ls
  220.         hReportStatus("Sorting complete.")
  221.       else
  222.       end if
  223.     end if
  224.     return 1
  225.   else
  226.   end if
  227. end
  228.  
  229. on hFindThisWord
  230.   hearit(gFTstartSND)
  231.   set Lwordtofind to field gInputField
  232.   hReportStatus("Fulltext search commencing for ‚Ä¢" & Lwordtofind & "‚Ä¢")
  233.   if gModeState = #TOPICS then
  234.     set gFTsearchscope to #ALL
  235.   end if
  236.   set LFTlist to [:]
  237.   if gFTsearchscope = #ALL then
  238.     put " across all modes." after field gStatusField
  239.     set Lhitlist to hLoadThreeFTs(Lwordtofind)
  240.     if not objectp(Lhitlist) then
  241.       hReportStatus("All-mode full text list containing >" & Lwordtofind & "< not retreivable.")
  242.       return 0
  243.     end if
  244.   else
  245.     put " in " & getaProp(gModeNameLU, gFTsearchscope) & " mode." after field gStatusField
  246.     set LFTlist to hLoadFTindex(Lwordtofind, gFTsearchscope)
  247.     if not objectp(LFTlist) then
  248.       hReportStatus("Full text list containing >" & Lwordtofind & "< not retreivable.")
  249.       hearit(gNopeSND)
  250.       return 0
  251.     end if
  252.     set Lwordtofind to hInitCap(Lwordtofind)
  253.     set Lhitlist to getaProp(LFTlist, Lwordtofind)
  254.   end if
  255.   if voidp(Lhitlist) then
  256.     set Lhitlist to hTryFTPlurals(LFTlist, Lwordtofind)
  257.   end if
  258.   if voidp(Lhitlist) then
  259.     set Lhitlist to hIsFTCurly(LFTlist, Lwordtofind)
  260.   end if
  261.   if not voidp(Lhitlist) then
  262.     set gTheFTword to Lwordtofind
  263.     set gNumofHits to count(Lhitlist)
  264.     hUserSelectWord()
  265.     hSetMode(#FoundSet)
  266.     set gStashedHitsList to Lhitlist
  267.     mSetupHitsList(oIndexScroller)
  268.     set gNewSetIsHereF to 0
  269.     put mSetOneFTfromLU(oSLlookup, gGlobalStepCount) into field gInputField
  270.     hilite char 999 of field gInputField
  271.     hMiniFind()
  272.     mReDefineSlider(oIndexSlider, 1, mGetModesMaxEntryNum(oIndexMediator) - 6, 0)
  273.   else
  274.     hReportStatus("That word not found in the full text database.")
  275.     hAnnounce("Selected Not Found...Search")
  276.   end if
  277. end
  278.  
  279. on hFillInputField pWithMe
  280.   put hcleanup(pWithMe) into field gInputField
  281.   hilite char 999 of field gInputField
  282. end
  283.  
  284. on hGrabStringNsearch pthefield
  285.   global gEditKeys
  286.   set Lwhichword to gTheMseWord
  287.   if Lwhichword > the number of words in field pthefield then
  288.     abort()
  289.   end if
  290.   if gFirstHotWord then
  291.     set x to word gFirstHotWord to gFirstHotWord + gchunksize - 1 of field pthefield
  292.     set Lthisstring to hIsaSeeListItem(word Lwhichword of field pthefield, x)
  293.     if not voidp(Lthisstring) then
  294.       set x to Lthisstring
  295.     end if
  296.     hFillInputField(x)
  297.     if gEditKeys then
  298.       if the controlDown and the commandDown then
  299.         hStoretheLink(x)
  300.       end if
  301.     end if
  302.     hFindThisEntry()
  303.   else
  304.     if Lwhichword > 0 then
  305.       if word Lwhichword of field pthefield = "SEE:" then
  306.         hCompileSEEtoFound(Lwhichword, pthefield)
  307.         abort()
  308.       end if
  309.       set lx to hcleanup(word Lwhichword of field pthefield)
  310.       hSwitchFTsearchscope(gModeState)
  311.       put lx into field gInputField
  312.       hilite char 999 of field gInputField
  313.       hFindThisWord()
  314.       hUserGrabWord()
  315.     end if
  316.   end if
  317. end
  318.  
  319. on hTryFTPlurals pList, pWord
  320.   set Lnum to the number of chars in pWord
  321.   if char Lnum of pWord = "s" then
  322.     hReportStatus("Translating possible plural word form.")
  323.     if char Lnum - 1 of pWord = "e" then
  324.       if char Lnum - 2 of pWord = "i" then
  325.         set pWord to hZapLastChar(pWord)
  326.         set pWord to hZapLastChar(pWord)
  327.         put "y" into char the number of chars in pWord of pWord
  328.       else
  329.         set pWord to hZapLastChar(pWord)
  330.         set pWord to hZapLastChar(pWord)
  331.       end if
  332.     else
  333.       set pWord to hZapLastChar(pWord)
  334.       if char Lnum - 1 of pWord = gAposCurlyQ then
  335.         set pWord to hZapLastChar(pWord)
  336.       end if
  337.     end if
  338.     return getaProp(pList, pWord)
  339.   end if
  340. end
  341.  
  342. on hIsFTCurly pList, pWord
  343.   if pWord contains "'" then
  344.     put gAposCurlyQ into char offset("'", pWord) of pWord
  345.     return getaProp(pList, pWord)
  346.   end if
  347. end
  348.  
  349. on hZapLastChar pWord
  350.   delete char the number of chars in pWord of pWord
  351.   return pWord
  352. end
  353.  
  354. on hPrepHyperExceptions
  355.   global gHyperExceptions
  356.   set gHyperExceptions to [:]
  357.   set gHyperExceptions to value(field "Hyperlink Exceptions")
  358.   if not objectp(gHyperExceptions) then
  359.     exit
  360.   end if
  361.   sort(gHyperExceptions)
  362.   hPrepLinkTrapper()
  363. end
  364.  
  365. on hSwapIfSpecial pEntry
  366.   global gHyperExceptions
  367.   set vHoldEntry to pEntry
  368.   set pEntry to getaProp(gHyperExceptions, pEntry)
  369.   if not voidp(pEntry) then
  370.     return pEntry
  371.   else
  372.     return vHoldEntry
  373.   end if
  374. end
  375.